package org.example.Server.controller.homework;

import lombok.extern.slf4j.Slf4j;
import org.example.Server.model.homework.HmkTechDTO;
import org.example.Server.service.homework.TeacherHomeworkService;
import org.example.Server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 教师端部分的课堂图文作业
 */
@RestController
@Slf4j
@RequestMapping("/youxich/homework/teacher")

public class TeacherHomeworkController {
    @Autowired
    private TeacherHomeworkService teacherHomeworkService;

    /**
     * 只添加作业标题和内容以及标准答案
     * @param hmkTechDTO
     * @param file
     * @return
     */
    @PostMapping("/base")
    public ResultAPI addHmkBase(HmkTechDTO hmkTechDTO,
                                @RequestParam(required = false) MultipartFile file,
                                @RequestParam(required = false) MultipartFile ans_file){
        return teacherHomeworkService.addHmkBase(hmkTechDTO,file,ans_file);
    }

    /**
     * 获得作业基础
     * @param homework_id
     * @return
     */
    @GetMapping("/base")
    public ResultAPI getHmkBase(@RequestParam Integer homework_id){
        return teacherHomeworkService.getHmkBase(homework_id);
    }

    /**
     * 更新高级设置
     * @param hmkTechDTO
     * @return
     */
    @PutMapping()
    public ResultAPI updateHmkSetting(@RequestBody  HmkTechDTO hmkTechDTO){
        return teacherHomeworkService.updateHmkSetting(hmkTechDTO);
    }

    /**
     * 更新作业基础
     * @param hmkTechDTO
     * @param file
     * @param ans_file
     * @return
     */
    @PutMapping("/base")
    public ResultAPI updateHmkBase(HmkTechDTO hmkTechDTO,
                                   @RequestParam(required = false) MultipartFile file,
                                   @RequestParam(required = false) MultipartFile ans_file){
        return teacherHomeworkService.updateHmkBase(hmkTechDTO,file,ans_file);
    }

    /**
     * 显示高级设置
     * @param homework_id
     * @return
     */
    @GetMapping("/setting")
    public ResultAPI getHmkSetting(@RequestParam Integer homework_id){
        return teacherHomeworkService.getHmkSetting(homework_id);
    }

    /**
     * 获取作业列表
     * @param semester_id
     * @return
     */
    @GetMapping
    public ResultAPI getHmkList(@RequestParam Integer semester_id){
        return teacherHomeworkService.getHmkList(semester_id);
    }

    /**
     * 作业概览
     * @param homework_id
     * @return
     */
    @GetMapping("/overview")
    public ResultAPI getHmkOverview(@RequestParam Integer homework_id){
        return teacherHomeworkService.getHmkOverview(homework_id);
    }

    /**
     * 批量删除作业列表
     * @param homework_ids
     * @return
     */
    @DeleteMapping("{homework_ids}")
    public ResultAPI deleteHmkList(@PathVariable List<Integer> homework_ids){
        return teacherHomeworkService.deleteHmkList(homework_ids);
    }

}
